// 导入axios实例
import httpRequest from '../request/index'


// 获取动漫全部年份
export function getYears() {
    return httpRequest({
        url: '/animation/years',
        method: 'get',
    });
}


// 获取全部动漫（年份分组）
export function getAll() {
    return httpRequest({
        url: '/animation/all',
        method: 'get',
    });
}

// 获取全部动漫（不分组）
export function getAllAnimation() {
    return httpRequest({
        url: '/animation/listall',
        method: 'get',
    });
}


// 分页获取动漫列表数据
export function getList(pageSize, pageNum) {
    return httpRequest({
        url: `/animation?pageSize=${pageSize}&pageNum=${pageNum}`,
        method: 'get',
    });
}


// 获取动漫全部集数链接
export function getAnimationLinks(id) {
    return httpRequest({
        url: `/animation/vlist?aid=${id}`,
        method: 'get',
    });
}


// 添加动漫
export function addAnimation(animation) {
    return httpRequest({
        baseURL: '/admin',
        url: `/animation/add`,
        method: 'post',
        data: animation,
        headers: { Authorization: window.sessionStorage.getItem('token') }
    });
}


// 编辑动漫
export function editAnimation(id, animation) {
    return httpRequest({
        baseURL: '/admin',
        url: `/animation/edit/${id}`,
        method: 'put',
        data: animation,
        headers: { Authorization: window.sessionStorage.getItem('token') }
    });
}


// 删除动漫
export function deleteAnimation(id) {
    return httpRequest({
        baseURL: '/admin',
        url: `/animation/${id}`,
        method: 'delete',
        headers: { Authorization: window.sessionStorage.getItem('token') }
    });
}


// 写评语
export function doAnimationComment(id, comment) {
    return httpRequest({
        baseURL: '/admin',
        url: `/animation/comment/${id}`,
        method: 'post',
        data: comment,
        headers: { Authorization: window.sessionStorage.getItem('token') }
    });
}
